import 'package:flutter/material.dart';

Future infoDialog(
  BuildContext context, {
  Widget? title,
  Widget? content,
  Widget? textOK,
  bool canPop = false,
  void Function(bool, dynamic)? onPopInvokedWithResult,
  Color? backgroundColor,
}) async {
  await showDialog(
    context: context,
    builder: (BuildContext context) => PopScope(
      canPop: canPop,
      onPopInvokedWithResult: onPopInvokedWithResult,
      child: AlertDialog(
        backgroundColor: backgroundColor,
        title: title,
        content: SingleChildScrollView(
          child: content ?? const Text(''),
        ),
        actions: <Widget>[
          TextButton(
            child:
                textOK ?? Text(MaterialLocalizations.of(context).okButtonLabel),
            onPressed: () => Navigator.pop(context, true),
          ),
        ],
      ),
    ),
  );
}
